#include <iostream>
#include <wiringSerial.h>
#include "cubeFunctions.h"
#include "cubeCommands.h"


#define BAUD_RATE 9600
#define SER_PORT "/dev/ttyUSB0"


int main(int argc, char ** argv)
{	
	// Initialize Tools
	bool continue = true;	// Continues Running Daemon until false
	char * cmdOutBuffer = new char[CMD_SIZE];	// For commands going out
	char * cmdInBuffer = new char[CMD_SIZE]; 	// For commands coming in

	int fd = serialOpen(SER_PORT, BAUD_RATE);	// Opens serial connection to XBee
	// Check if serial connection worked
	if(fd >= 0)
	{
		std::cout << "USB connection to XBee successful!" << std::endl; 
	}
	else
	{
		std::cout << "Error Opening USB" << std::endl; 	
		return -1;	// Exit on Error
	}

	// Main loop
	// Goes through the main modes of the cube
	while(continue)
	{
		// Check inputs 
			// Button checking - start a game? 
		
		// Comm check - perform a command? 
		if(serialDataAvail(fd) > 0)
			getExCommand(fd);	// Gets and executes command

		// In game
			




	
	
	return 0; 
}
